<?php

class DebugUtil
{	
	public static function PrintVar($arg1, $arg2 = null)
	{
		for ($i = 0, $numArgs = func_num_args(); $i < $numArgs ; $i++)
		{
			echo '<pre>';
			echo "\n---------------- <font color='red'><b> DEBUG </b></font> --------------- \n";
			$var = func_get_arg($i);
			if (is_array($var))
			{
				print_r($var);
			}
			elseif ($var instanceof IIterator)
			{
				echo "<hr>";
				if (!$it->hasNext())
				{
					echo "<b>Nao trouxe Registros</b>";
				}
				else
				{
					$i = 0;
					while ($it->hasNext())
					{
						$i++;
						$sr = $it->moveNext();
						if ($i>100)
						{
							break;
						}
						
						$arr = $sr->getFieldNames();
						foreach ($arr as $key=>$value)		
						{
							echo $value."=>".$sr->getField($value)."\n";	
						}
						echo "\n\n";				
					}
				}
			}
			else 
			{
				echo $var;
			}
			echo "\n";
			echo '</pre>';
		}
	}
	
	public static function PrintValue($value, $info = null)
	{
		echo '<pre>';
		echo "\n---------------- <font color='red'><b> DEBUG </b></font> --------------- \n";
		
		if ($info)
		{
			echo $info;
			echo "\n";
		}
		
		if (is_array($value) || (is_object($value)))
		{
			print_r($value);
		}
		else if(is_bool($value))
		{
			if ($value === true)
			{
				echo 'true';
			}
			else
			{
				echo 'false';
			}
		}
		else
		{
			echo $value;
		}		
		
		echo "\n";
		echo '</pre>';
		
		ob_end_flush();
		flush();
	}
}
?>